############## 构建 libmaxminddb #####################
FROM gcc:9 AS libmaxminddb-build
ADD lib/libmaxminddb-1.9.1.tar.gz /
WORKDIR /libmaxminddb-1.9.1
RUN ./configure && make && make install && ldconfig -v && ls -f  /usr/local/lib/libmaxminddb*

############## 构建 openresty #####################
FROM openresty/openresty:centos-rpm
ENV TZ Asia/Shanghai
COPY --from=libmaxminddb-build   /usr/local/lib/libmaxminddb.so.0.0.7 /lib64
COPY  geoip/20240112/Country.mmdb /etc/nginx/mmdb/Country.mmdb

RUN  ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime && echo "$TZ" > /etc/timezone \
     && opm get anjia0532/lua-resty-maxminddb \
     && ln -s /lib64/libmaxminddb.so.0.0.7 /lib64/libmaxminddb.so \
     && ldconfig -v